package monster.com.cvh.manager;

import android.app.ProgressDialog;
import android.content.Context;

import monster.com.cvh.R;


/**
 * @author: pengguanming
 * @data: 2018/10/25
 * @function:等待Dialog单例
 */
public class DialogManager {
    private static ProgressDialog mDialog;

    private DialogManager() {

    }

    public static DialogManager getInstance(Context context) {
        return SingletonHolder.INSTANCE;
    }

    public void showProgressDialog(Context context) {
        if (mDialog == null) {
            mDialog = new ProgressDialog(context);
            mDialog.setMessage(context.getResources().getString(R.string.please_wait));
            mDialog.setCanceledOnTouchOutside(false);
            mDialog.setCancelable(false);
        }
        mDialog.show();
    }

    public void dismissProgressDialog() {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        mDialog = null;
    }

    private static class SingletonHolder {
        private static final DialogManager INSTANCE = new DialogManager();
    }
}
